package cn.itcast.service.cargo.impl;
/*
 * -------------------------------------------------------
 * Copyright (c) 2020, kachu
 * All rights reserved.
 * FileName：
 * Description：描述
 * History：V1.0
 * 2020/10/6 14:10  kachu  Desc
 * -------------------------------------------------------
 */

import cn.itcast.dao.cargo.FinanceDao;
import cn.itcast.domain.cargo.Finance;
import cn.itcast.service.cargo.FinanceService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.UUID;

/**
 * @author kachu
 * @version v1.0
 */
@Service(timeout = 1000000)
public class FinanceServiceImpl implements FinanceService {

    /**
     * 获取财务报运单持久层对象
     */
    @Autowired
    private FinanceDao financeDao;

    /**
     * 查找所有
     *
     * @return 财务报运单集合
     */
    @Override
    public List<Finance> findAll() {
        return financeDao.findAll();
    }

    /**
     * 根据id查找
     *
     * @param id 财务报运单id
     * @return 财务报运单对象
     */
    @Override
    public Finance findById(String id) {
        return financeDao.findById(id);
    }

    /**
     * 保存（新建）
     *
     * @param finance 财务报运单对象
     */
    @Override
    public void save(Finance finance) {
        finance.setId(UUID.randomUUID().toString());
        financeDao.save(finance);
    }

    /**
     * 修改
     *
     * @param finance 财务报运单对象
     */
    @Override
    public void update(Finance finance) {
        financeDao.update(finance);
    }

    /**
     * 分页查询
     *
     * @param pageNum  当前页
     * @param pageSize 页面大小
     * @return 页面对象
     */
    @Override
    public PageInfo<Finance> findByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Finance> list = financeDao.findAll();
        return new PageInfo<>(list);
    }
}
